﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <button onclick="run()">暂停</button> 
    <button onclick="state()">开始</button>
    <script>
        var I = 0;
        var time = setInterval(function () {
            I++;
            console.log(`定时器被执行了${I}`);
        }, 200);
        function run() {
            clearInterval(time);
        }
        function state() {
            time = setInterval(function () {
                I++
                console.log(`定时器被执行了${I}`);
            }, 200)
        }
        let time2 = setTimeout(function () {
            console.log(`setTimeout被执行了`);
        }, 1000)
    </script>
</body>
</html>